package com.distributedDataBase.action;

import com.distributedDataBase.pojo.Result;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("cookie")
public class CookieAction {

    @GetMapping("add")
    public Result addCookie(HttpServletResponse response){
        //创建一个Cookie
        Cookie cookie = new Cookie("loginInfo","admin:123456");
        //将这个cookie发送到客户端
        response.addCookie(cookie);

        return new Result("200","cookie");
    }
}
